package com.pxsw.mobile.hcd.act;

import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.mdx.mobile.activity.MActivity;
import com.mdx.mobile.server.Son;
import com.pxsw.mobile.hcd.R;

public class AddItemAct extends MActivity {
	
	private Button takepicture;
	private Dialog dialog;
	@Override
	protected void create(Bundle arg0) {
		this.setContentView(R.layout.frame_additem);
		takepicture=(Button)findViewById(R.frame_additem.takepicture);
		takepicture.setOnClickListener(new OnClickListener() {

			public void onClick(View v) {
				// TODO Auto-generated method stub
				ShowPickDialog();
			}
		});
	}
	
	private void ShowPickDialog() {
		dialog = new Dialog(this, R.style.Dialog);
		dialog.setContentView(R.layout.cameradialog);
		View view = dialog.getWindow().getDecorView();
		(view.findViewById(R.cameradialog.capture))
				.setOnClickListener(new OnClick());
		(view.findViewById(R.cameradialog.pick))
				.setOnClickListener(new OnClick());
		dialog.show();
	}
	
	public class OnClick implements OnClickListener {

		public void onClick(View v) {
			// TODO Auto-generated method stub
			switch (v.getId()) {
			case R.cameradialog.pick:
				Intent pick = new Intent(AddItemAct.this, StreamCameraAct.class);
				pick.putExtra("type", "1");
				startActivity(pick);
				dialog.dismiss();
				dialog.cancel();
				break;
			case R.cameradialog.capture:
				Intent capture = new Intent(AddItemAct.this, StreamCameraAct.class);
				capture.putExtra("type", "2");
				startActivity(capture);
				dialog.dismiss();
				dialog.cancel();
				break;
			}
		}
	}
	

	@Override
	public void dataLoad(int[] types) {
		// TODO Auto-generated method stub
		super.dataLoad(types);
	}

	@Override
	public void disposeMessage(Son son) throws Exception {
		// TODO Auto-generated method stub
		super.disposeMessage(son);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
	}

}
